home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / tcl / tcl70b2.lha / tcl7.0b2 / doc / LinkVar.3 < prev    next >
Text File  |  1993-06-09  |  5KB  |  120 lines

  1. '\"
  2. '\" Copyright (c) 1993 The Regents of the University of California.
  3. '\" All rights reserved.
  4. '\"
  5. '\" Permission is hereby granted, without written agreement and without
  6. '\" license or royalty fees, to use, copy, modify, and distribute this
  7. '\" documentation for any purpose, provided that the above copyright
  8. '\" notice and the following two paragraphs appear in all copies.
  9. '\"
  10. '\" IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY
  11. '\" FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
  12. '\" ARISING OUT OF THE USE OF THIS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
  13. '\" CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  14. '\"
  15. '\" THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
  16. '\" INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
  17. '\" AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
  18. '\" ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
  19. '\" PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
  20. '\" 
  21. '\" $Header: /user6/ouster/tcl/man/RCS/LinkVar.3,v 1.1 93/06/09 12:00:20 ouster Exp $ SPRITE (Berkeley)
  22. '\" 
  23. .so man.macros
  24. .HS Tcl_LinkVar tclc 7.0
  25. .BS
  26. .SH NAME
  27. .na
  28. Tcl_LinkVar, Tcl_UnlinkVar, Tcl_LinkedVarWritable \- link Tcl variable to C variable
  29. .ad
  30. .SH SYNOPSIS
  31. .nf
  32. \fB#include <tcl.h>\fR
  33. .sp
  34. int
  35. \fBTcl_LinkVar\fR(\fIinterp, varName, addr, type\fR)
  36. .sp
  37. \fBTcl_UnlinkVar\fR(\fIinterp, varName\fR)
  38. .sp
  39. \fBTcl_LinkedVarWritable\fR(\fIinterp, varName, writable\fR)
  40. .SH ARGUMENTS
  41. .AS Tcl_Interp writable
  42. .AP Tcl_Interp *interp in
  43. Interpreter that contains \fIvarName\fR.
  44. Also used by \fBTcl_LinkVar\fR to return error messages.
  45. .AP char *varName in
  46. Name of global variable.
  47. .AP char *addr in
  48. Address of C variable that is to be linked to \fIvarName\fR.
  49. .AP int type in
  50. Type of C variable.  Must be TCL_LINK_INT, TCL_LINK_REAL,
  51. TCL_LINK_BOOLEAN, or TCL_LINK_STRING.
  52. .BE
  53.  
  54. .SH DESCRIPTION
  55. .PP
  56. \fBTcl_LinkVar\fR uses variable traces to keep the Tcl variable
  57. named by \fIvarName\fR in sync with the C variable at the address
  58. given by \fIaddr\fR.
  59. Whenever the Tcl variable is read the value of the C variable will
  60. be returned, and whenever the Tcl variable is written the C
  61. variable will be updated to have the same value.
  62. \fBTcl_LinkVar\fR normally returns TCL_OK;  if an error occurs
  63. while setting up the link (e.g. because \fIvarName\fR is the
  64. name of array) then TCL_ERROR is returned and \fIinterp->result\fR
  65. contains an error message.
  66. .PP
  67. The \fItype\fR argument specifies the type of the C variable,
  68. and must have one of the following values:
  69. .TP
  70. \fBTCL_INT\fR
  71. The C variable is of type \fBint\fR.
  72. Any value written into the Tcl variable must have a proper integer
  73. form acceptable to \fBTcl_GetInt\fR;  attempts to write
  74. non-integer values into \fIvarName\fR will be rejected with
  75. Tcl errors.
  76. .TP
  77. \fBTCL_DOUBLE\fR
  78. The C variable is of type \fBdouble\fR.
  79. Any value written into the Tcl variable must have a proper real
  80. form acceptable to \fBTcl_GetDouble\fR;  attempts to write
  81. non-real values into \fIvarName\fR will be rejected with
  82. Tcl errors.
  83. .TP
  84. \fBTCL_BOOLEAN\fR
  85. The C variable is of type \fBint\fR.
  86. If its value is zero then it will read from Tcl as ``0'';
  87. otherwise it will read from Tcl as ``1''.
  88. Whenver \fIvarName\fR is
  89. modified, the C variable will be set to a 0 or 1 value.
  90. Any value written into the Tcl variable must have a proper boolean
  91. form acceptable to \fBTcl_GetBoolean\fR;  attempts to write
  92. non-boolean values into \fIvarName\fR will be rejected with
  93. Tcl errors.
  94. .TP
  95. \fBTCL_STRING\fR
  96. The C variable is of type \fBchar *\fR.
  97. If its value is not null then it must be a pointer to a string
  98. allocated with \fBmalloc\fR.
  99. Whenever the Tcl variable is modified the current C string will be
  100. freed and new memory will be allocated to hold a copy of the variable's
  101. new value.
  102. If the C variable contains a null pointer then the Tcl variable
  103. will read as ``NULL''.
  104. .PP
  105. The procedure \fBTcl_UnlinkVar\fR removes the link associated with
  106. \fIvarName\fR, making the C variable and the Tcl variable independent
  107. again.
  108. .PP
  109. \fBTcl_LinkedVarWritable\fR can be used to make a linked variable
  110. read-only from Tcl, so that its value can only be changed by modifing
  111. the C variable.
  112. The \fBwritable\fR argument specifies whether the Tcl variable is
  113. to be writable or not:  0 makes the variable read-only
  114. and non-zero makes it writable again.
  115. If the Tcl variable is read-only then attempts to write it
  116. will be rejected with Tcl errors.
  117.  
  118. .SH KEYWORDS
  119. boolean, integer, link, read-only, real, string, variable
  120.